get_json_file(){
  begin=`grep -n "showing report" /tmp/out | awk -F ':' '{print $1}'`
  end=`grep -n "PLAY RECAP" /tmp/out | awk -F ':' '{print $1}'`
  begin=`expr ${begin} + 1`
  end=`expr ${end} - 1`
  sed -n "${begin},${end}p" /tmp/out > /tmp/out1
}

call_ansible_check(){
  ansible-playbook check_k8s_cluster_status.yml -e hostsgroup=$1 --tags=$2 > /tmp/out
  get_json_file
  python3 analysis_regist_msg.py /tmp/out1 stdout
}

pip3 install colorama

echo "ansible-playbook check_k8s_cluster_status.yml" 
call_ansible_check k8smaster master

echo "check k8s node status"
call_ansible_check k8snode node

echo "check etcd status"
call_ansible_check etcd etcd

master_top1_ip=`python3 get_ansible_host_group_msg.py k8smaster | awk 'NR==1{print}'`
ansible-playbook check_k8s_cluster_status.yml -e hostsgroup=$master_top1_ip --tags=kube-system > /tmp/out
get_json_file
python3 analysis_regist_msg.py /tmp/out1 aaaa

